package com.neuedu.corejava.ch12.homework;

import java.io.File;

public class showFile {

	public static int totol = 0;  //文件
	public static int dirtotol = 0; //文件夹

	public static String showFile(String path) {
		
		File file = new File(path);
		String[] fileArr = file.list();
		
		for (int i = 0; i < fileArr.length; i++) {
			String nowPath = path + "\\" + fileArr[i];
			File file1 = new File(nowPath);
			if (file1.isDirectory()) {
				showFile(nowPath);
				dirtotol++;
			} else {
				System.out.println("文件名：" + file1.getName());
				System.out.println("路径名：" + nowPath);
				totol++;
				System.out.println("-----------------");
			}
		}

		return "";
	}

	public static void main(String[] args) {
		System.out.println("列出该文件夹中的所有的文件名和文件的路径");
		showFile("D:\\temp");
		System.out.println("总共有" + totol + "个文件，文件夹有" + dirtotol + "个");

	}

}
